package com.orkasgb.framework.hadoop.mapperreduce.partitioner;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class PartitionerReduce extends Reducer<Text, PartitionerEntity, NullWritable, PartitionerEntity> {

    @Override
    protected void reduce(Text key, Iterable<PartitionerEntity> values, Context context) throws IOException, InterruptedException {
        for (PartitionerEntity entity : values) {
            entity.setTotle(entity.getChiness() + entity.getEnglish() + entity.getMath() +
                    entity.getHistory() + entity.getPhysics());
            context.write(NullWritable.get(), entity);
        }
    }
}
